package net.mingsoft.basic.util;

public class UrlEncoderUtils
{
    public static boolean hasUrlEncoded(final String str) {
        boolean encode = false;
        int i = 0;
        while (i < str.length()) {
            final char c = str.charAt(i);
            if (c == '%' && i + 2 < str.length()) {
                final char c2 = str.charAt(i + 1);
                final char c3 = str.charAt(i + 2);
                if (isValidHexChar(c2) && isValidHexChar(c3)) {
                    encode = true;
                    break;
                }
                break;
            }
            else {
                ++i;
            }
        }
        return encode;
    }
    
    private static boolean isValidHexChar(final char c) {
        return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F');
    }
}
